package com.yswy.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yswy.common.enums.TfPlatformEnums;
import com.yswy.common.enums.XtPlatformEnums;
import com.yswy.common.enums.base.TypeEnum;
import com.yswy.domain.common.BasePojo;
import com.yswy.domain.entity.user.User;
import com.yswy.domain.vo.gld.addOrUpate.PackageVersionAddOrUpdate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
@AllArgsConstructor
@Api(tags = "版本管理")
@TableName(value = "package_version")
public class PackageVersion extends BasePojo<PackageVersion> {

    @ApiModelProperty("项目ID")
    private Long projectId;
    @ApiModelProperty("项目名字")
    @TableField(exist = false)
    private String projectName;

    @ApiModelProperty("文件地址")
    private String fileUrl;
    @ApiModelProperty("版本号")
    private String versionCode;
    @ApiModelProperty("版本")
    private Integer version;
    @ApiModelProperty("是否发布 0未发布,1已发布")
    private Integer isRelease;
    @ApiModelProperty("是否强制更新  0 不强制更新   1 强制更新")
    private Integer isForce;
    @ApiModelProperty("系统平台  0 android  1 ios ")
    private String xtPlatform;

    @ApiModelProperty("附加字段")
    private String  appendInformation ;
    @ApiModelProperty("更新公告")
    private String  notice ;



    public PackageVersion(PackageVersionAddOrUpdate res , User user) {
        this.projectId = res.getProjectId();
        this.fileUrl = res.getFileUrl();
        this.versionCode = "V"+res.getVersionCode();
        String version = res.getVersionCode().replace(".","");
        this.version =Integer.parseInt(version);
        this.isRelease = res.getIsRelease();
        this.isForce = res.getIsForce();

        TypeEnum typeEnum = TypeEnum.messageOf(XtPlatformEnums.class , res.getXtPlatform());
        String xtPlatform = typeEnum.toString();
        this.xtPlatform =xtPlatform;
        this.appendInformation =res.getAppendInformation();
        this.notice = res.getNotice() ;
        super.setCreateBy(user.getId().longValue());
    }
    public PackageVersion() {

    }
}
